| Conditions | 3 |
| Total Lines | 22 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import log from './log'; |
||
| 5 | |||
| 6 | function mysql_connection(): null | mysql.Connection { |
||
| 7 | var result = null; |
||
| 8 | if (config.hasOwnProperty('database')) { |
||
| 9 | const database = config.database; |
||
| 10 | var con = mysql.createConnection({ |
||
| 11 | host: database.host, |
||
| 12 | user: database.user, |
||
| 13 | password: database.pass, |
||
| 14 | port: Number(database.port), |
||
| 15 | database: database.dbname, |
||
| 16 | }); |
||
| 17 | con.connect(function (err: any) { |
||
| 18 | if (err) { |
||
| 19 | log.log(log.error(err)); |
||
| 20 | } else { |
||
| 21 | log.log(log.success('Connected!')); |
||
| 22 | result = con; |
||
| 23 | } |
||
| 24 | }); |
||
| 25 | } |
||
| 26 | return result; |
||
| 27 | } |
||
| 31 |